<!DOCTYPE html>
<html>

<head>
    <meta charset="utf8" />
    <title>工具箱</title>
    <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"
        type="application/javascript"></script>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <h2>GitHub地址转CDN</h2>
        GitHub地址：<input type="text" v-model.trim="githubUrl" style="width:500px;" />
        <br />
        CDN地址：<a :href="jsdelivrUrl" target="_blank">{{jsdelivrUrl}}</a>
        <br />
        资源地址：<a :href="fastgitUrl" target="_blank">{{fastgitUrl}}</a>
        <hr />
        <h2>Node-RED密码生成</h2>
        明文密码：<input type="text" v-model.trim="NodeRedPassword" />
        <br />
        密文：<mark>{{bcryptNodeRedPassword}}</mark>
        <hr />
        <h2>MD5加密</h2>
        文本字符串：<input type="text" v-model.trim="md5Before" />
        <br />
        32位：<mark>{{md5After}}</mark>
        <br />
        16位：<mark>{{ md5After != '' ? md5After.substr(8,16) : "" }}</mark>
        <hr />
    </div>
    <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/bcryptjs/2.4.3/bcrypt.min.js"
        type="application/javascript"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data() {
                return {
                    githubUrl: "",
                    NodeRedPassword: "",
                    md5Before: ""
                }
            },
            computed: {
                jsdelivrUrl() {
                    return this.githubUrl
                        .replace("https://github.com", "https://cdn.jsdelivr.net/gh")
                        .replace("/blob/", "@");
                },
                fastgitUrl() {
                    return this.githubUrl
                        .replace("https://github.com", "https://hub.fastgit.org")
                },
                bcryptNodeRedPassword() {
                    const { NodeRedPassword } = this
                    if (NodeRedPassword) return dcodeIO.bcrypt.hashSync(NodeRedPassword, 8)
                },
                md5After() {
                    const { md5Before } = this
                    if (md5Before !== '') return md5(md5Before)
                    return ''
                }
            },
            methods: {
                // 明文与密文比较
                compare(pwd1, pwd2) {
                    dcodeIO.bcrypt.compare(pwd1, pwd2, function (err, res) {
                        console.log(res)
                    });
                }
            }
        })
    </script>
    <script async src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/blueimp-md5/2.19.0/js/md5.min.js"
        type="application/javascript"></script>
</body>

</html>